import Vue from 'vue'
import Vuex from 'vuex'
/* eslint-disable */
Vue.use(Vuex)
const mutations = {
    addTodo (state, options) {
        let id = state.list.length == 0 ? 1 : state.list[state.list.length - 1].id + 1
        state.list.push({
            id,
            name: options.name,
            done: false
        })
    },
    cleanTodo (state) {
        state.list = state.list.filter(item => !item.done)
    },
    delTodo (state, options) {
        state.list = state.list.filter(item => item.id != options.id)
    }
}

const state = {
    list: [
        { id: 1, name: 'catlu is infinity', done: true },
        { id: 2, name: '竞峰 is ....', done: true },
        { id: 3, name: '高翔 is baka', done: false }
    ]
}

const store = new Vuex.Store({
    state,
    mutations
})

export default store